package com.qf.device.controller;

import com.qf.device.service.CmdService;
import com.qf.dto.CmdParamDto;
import com.qf.vo.R;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 作者：熊剑
 * 时间：2023/11/1
 * 描述：
 */
@RestController
@CrossOrigin
@RequestMapping("device")
@Slf4j
public class CmdController {

    @Autowired
    private CmdService cmdService;

    @PostMapping("cmd")
    public R cmd(@RequestBody CmdParamDto cmdParamDto) {
        try {
            R send = cmdService.send(cmdParamDto);
            return send;
        } catch (MqttException e) {
            log.error(e.getMessage(), e);
        }
        return null;
    }
}
